package com.bgIntlgn.client.entity.sells;

import java.util.Date;

import yuhuibear.poat.annotations.action.AutoGenerateValue;
import yuhuibear.poat.annotations.relation.Field;
import yuhuibear.poat.annotations.relation.Table;
import yuhuibear.poat.object.bean.Bean;

/**
 * 订单
 * 
 * @author yuhui
 * 
 */
@Table(name = "orders", constrain = "")
public class Order implements Bean {

	@AutoGenerateValue(skipOnNull = true, sqlToGet = "select currval('orders_id_seq')")
	@Field(name = "id", type = "bigserial", constrain = "primary key ")
	private Long id;

	@Field(name = "order_date", type = "timestamp", constrain = "")
	private Date orderDate;

	@Field(name = "serial_number", type = "varchar(80)", constrain = "unique")
	private String serialNumber;

	@Field(name = "custom_id", type = "int8", constrain = " references customs(id)  on update cascade ")
	private Long customId;

	@Field(name = "contactor_id", type = "int8", constrain = " references contactors(id)  on update cascade ")
	private Long contactorId;

	@Field(name = "plan", type = "boolean", constrain = "default false")
	private boolean plan = false;

	/**
	 * 付款方式
	 */
	@Field(name = "payment", type = "int8", constrain = "not null references dictionarys(id)  on update cascade ")
	private Long payment;

	/**
	 * 订单总金额
	 */
	@Field(name = "sum", type = "float ", constrain = "not null default 0.0")
	private Double sum;

	/**
	 * 销售人员
	 */
	@Field(name = "seller", type = "int8", constrain = " references employees(id)  on update cascade ")
	private Long seller;

	/**
	 * 创建人.
	 */
	@Field(name = "creater", type = "int8", constrain = "references employees(id)  on update cascade ")
	private Long creater;

	/**
	 * 订单状态
	 * 
	 * @author yuhui
	 * 
	 */
	public enum State {
		draft(0), order(1), histroy(2);

		int data = 0;

		private State(int i) {
			data = i;
		}

		public int getValue() {
			return data;
		}
	}

	/**
	 * 订单状态: 见如上的枚举类.
	 */
	@Field(name = "states", type = "int", constrain = "not null ")
	private int states;

	/**
	 * 订单优先级 ， 这个优先级会向生产和采购传播
	 */
	@Field(name = "priority", type = "int ", constrain = "default 0")
	private Integer priority = 0;

	/**
	 * 订单备注
	 */
	@Field(name = "comment", type = "varchar(1000)", constrain = "")
	private String comment;

	private boolean paid; // 标记是否回款完毕

	private boolean delibered; // 标记是否发货完毕

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getOrderDate() {
		return this.orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public String getSerialNumber() {
		return this.serialNumber;
	}

	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}

	public Long getCustomId() {
		return this.customId;
	}

	public void setCustomId(Long customId) {
		this.customId = customId;
	}

	public Long getContactorId() {
		return this.contactorId;
	}

	public void setContactorId(Long contactorId) {
		this.contactorId = contactorId;
	}

	public Double getSum() {
		return this.sum;
	}

	public void setSum(Double sum) {
		this.sum = sum;
	}

	public String getComment() {
		return this.comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Long getPayment() {
		return this.payment;
	}

	public void setPayment(Long payment) {
		this.payment = payment;
	}

	public Long getSeller() {
		return this.seller;
	}

	public void setSeller(Long seller) {
		this.seller = seller;
	}

	public int getStates() {
		return this.states;
	}

	public void setStates(int states) {
		this.states = states;
	}

	public Integer getPriority() {
		return this.priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

	public boolean isPaid() {
		return paid;
	}

	public void setPaid(boolean paid) {
		this.paid = paid;
	}

	public boolean isDelibered() {
		return delibered;
	}

	public void setDelibered(boolean delibered) {
		this.delibered = delibered;
	}

	public boolean isPlan() {
		return plan;
	}

	public void setPlan(boolean plan) {
		this.plan = plan;
	}

	public Long getCreater() {
		return creater;
	}

	public void setCreater(Long creater) {
		this.creater = creater;
	}

}
